subroutine WForObject(params,ig,jg,ggu,ggl,di,f,l1,v1,v2,v3,&
    v4,v5,ggl2,ggu2,di2,vertex3D,nVer3D,nInCat3D,igT3D,jgT3D,&
    ggT3D,igEarth,jgEarth,log_txt,zLayers,nLayers,areaObjects,areaType,&
    nAreaObjects,xObjects,yObjects,zObjects,numbersObjects,nXObjects,&
    nYObjects,nZObjects,nObjects,numArea,v0,wa)
    common /dim3D/nodesCount3D,elemsCount3D,nodesBoundCount3D,&
    edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,nodesTermCount3D,&
    m3D,mTerm3d,nodesNotTermCount3D
    common /commonInfo/ eps2d,eps3d,eps3dNS,radiusRED,maxiter,typeTask,nt,nMaterials,calcWK,calcVP
    common /dimEarth/nodesNotTermEarth,mEarth
    integer log_txt,areaObjects,areaType
    integer edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,elemsCount3D,elementsEarth
    real*8 eps2d,eps3d,eps3dNS,radiusRED,ggT3D,wa,zLayers,v0,xObjects,yObjects,zObjects
    real*8 vertex3D,params,ggu,ggl,di,f,v1,v2,v3,v4,v5,residual,ggl2,ggu2,di2
    dimension params(2,nMaterials),ig(nodesNotTermCount3D+1),jg(m3d),ggu(m3d),&
    ggl(m3d),di(nodesNotTermCount3D),f(nodesNotTermCount3D),l1(nodesBoundCount3D),&
    v1(nodesNotTermCount3D),v2(nodesNotTermCount3D),v3(nodesNotTermCount3D),&
    v4(nodesNotTermCount3D),v5(nodesNotTermCount3D),ggl2(m3d),ggu2(m3d),&
    di2(nodesNotTermCount3D),vertex3D(3,nodesCount3D),nVer3D(14,elemsCount3D),&
    nInCat3D(elemsCount3D),igT3D(nodesTermCount3D+1),jgT3D(mTerm3d),&
    ggT3D(mTerm3d),wa(nodesCount3D),igEarth(nodesNotTermEarth+1),jgEarth(mEarth),&
    zLayers(nLayers),v0(nodesCount3D),areaObjects(nAreaObjects),&
    areaType(2,nLayers+nObjects),xObjects(nXObjects),yObjects(nYObjects),&
    zObjects(nZObjects),numbersObjects(6,nObjects)

    call clearVectorDouble(wa,nodesCount3D)
    !Assembling global matrix
    call globalWForObject(ggl,ggu,di,f,vertex3D,nVer3D,nInCat3D,ggT3D,&
    igT3D,jgT3D,ig,jg,v0,zLayers,nLayers,areaObjects,areaType,&
    nAreaObjects,xObjects,yObjects,zObjects,numbersObjects,nXObjects,&
    nYObjects,nZObjects,nObjects,numArea,params)
    !Taking into account boundary condition
    call firstCondition(di,f,l1,nodesNotTermCount3D,nodesBoundCount3D,1)
     k=1
    do i=1,nodesNotTermEarth
        j=ig(i)
        do while(j<=ig(i+1)-1.and.jg(j)<=nodesNotTermEarth)
            ggl2(k)=ggl(j)
            ggu2(k)=ggu(j)
            j=j+1
            k=k+1
        enddo 
    enddo

    !Solving SLAE
    call LOS2(wa,f,igEarth,jgEarth,ggl2,ggu2,di,nodesNotTermEarth,mEarth,&
    maxiter,eps3d,v1,v2,v3,v4,v5,0,iter,residual)
    call calculateValueForNotTermNodes(wa,igT3D,jgT3D,ggT3D,nodesCount3D,&
    mTerm3d,nodesTermCount3D,nodesNotTermCount3D)

2   format(A,i5,' residual =',E)
    write(*,2) 'VP: end W_a:       iter =',iter,residual
    write(log_txt,2) 'VP: end W_a:       iter =',iter,residual
end
!*************************************************************************
subroutine globalWForObject(ggl,ggu,di,f,vertex3D,nVer3D,nInCat3D,ggT3D,&
    igT3D,jgT3D,ig,jg,v0,zLayers,nLayers,areaObjects,areaType,nAreaObjects,&
    xObjects,yObjects,zObjects,numbersObjects,nXObjects,nYObjects,&
    nZObjects,nObjects,numArea,params)
    common /dim3D/nodesCount3D,elemsCount3D,nodesBoundCount3D,edgesTermCount3D,&
    edgesNotTermCount3D,edgesCount3D,nodesTermCount3D,m3D,mTerm3d,nodesNotTermCount3D
    common /commonInfo/ eps2d,eps3d,eps3dNS,radiusRED,maxiter,typeTask,nt,nMaterials,calcWK,calcVP
    integer edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,elemsCount3D,&
    typeTask,calcWK,calcVP,areaObjects,areaType
    real*8 vertex3D,params,ggu,ggl,di,f,ggl2,ggu2,di2,zLayers,v0,&
    xObjects,yObjects,zObjects,ggT3D,v,b,x1,x2,y1,y2,z1,z2,g,sigma,&
    eps2d,eps3d,eps3dNS,radiusRED
    dimension params(2,nMaterials),ig(nodesNotTermCount3D+1),jg(m3d),ggu(m3d),ggl(m3d),&
    di(nodesNotTermCount3D),f(nodesNotTermCount3D),vertex3D(3,nodesCount3D),&
    nVer3D(14,elemsCount3D),nInCat3D(elemsCount3D),igT3D(nodesTermCount3D+1),&
    jgT3D(mTerm3d),ggT3D(mTerm3d),v(8),b(8,8),g(8),zLayers(nLayers),&
    v0(nodesCount3D),areaObjects(nAreaObjects),areaType(2,nLayers+nObjects),&
    xObjects(nXObjects),yObjects(nYObjects),zObjects(nZObjects),numbersObjects(6,nObjects)

    call clear(ggl,ggu,di,f,nodesNotTermCount3D,m3D)
    do i=1,elemsCount3D
        x1=vertex3D(1,nVer3D(1,i))
        x2=vertex3D(1,nVer3D(2,i))
        y1=vertex3D(2,nVer3D(1,i))
        y2=vertex3D(2,nVer3D(3,i))
        z1=vertex3D(3,nVer3D(1,i))
        z2=vertex3D(3,nVer3D(5,i))
        sigma=params(1,nInCat3D(i))
        do j=1,8
            v(j)=v0(nVer3D(j,i))
        enddo

        !Assembling local matrix
        call LocalMatrixWForObject(b,g,x1,x2,y1,y2,z1,z2,&
        v,sigma,numArea,zLayers,nLayers,xObjects,yObjects,&
        zObjects,numbersObjects,nXObjects,nYObjects,nZObjects,&
        nObjects)

        !Adding local matrix to global
        call AddLocal(di,ig,jg,ggl,ggu,f,b,g,nVer3D(1,i),nodesNotTermCount3D,&
        m3D,8,igT3D,jgT3D,ggT3D,nodesTermCount3D,mTerm3d,1)
    enddo
end
!*************************************************************************
!Assembling local matrix
subroutine LocalMatrixWForObject(b,g,x1,x2,y1,y2,z1,z2,v,sigma,numArea,&
    zLayers,nLayers,xObjects,yObjects,zObjects,numbersObjects,nXObjects,&
    nYObjects,nZObjects,nObjects)
    dimension b1(2,2),c1(2,2),b(8,8),g(8),v(8),zLayers(nLayers+1),&
    xObjects(nXObjects),yObjects(nYObjects),zObjects(nZObjects),&
    numbersObjects(6,nObjects)
    real*8 b1,c1,b,hx,hy,hz,g,x1,x2,y1,y2,z1,z2,v,sigma,&
    zLayers,xObjects,yObjects,zObjects
    integer deltaObject,d

    b1(1,1)=1.d0
    b1(1,2)=-1.d0
    b1(2,1)=-1.d0
    b1(2,2)=1.d0

    c1(1,1)=2.d0/6.d0
    c1(1,2)=1.d0/6.d0
    c1(2,1)=1.d0/6.d0
    c1(2,2)=2.d0/6.d0

    hx=x2-x1
    hy=y2-y1
    hz=z2-z1
    do i=1,8
        do j=1,8
            mi=mu_3d(i)
            mj=mu_3d(j)
            ni=nu_3d(i)
            nj=nu_3d(j)
            ki=ku_3d(i)
            kj=ku_3d(j)
            b(i,j)=(1.d0/hx*b1(mi,mj)*hy*c1(ni,nj)*hz*c1(ki,kj)+&
            hx*c1(mi,mj)*1.d0/hy*b1(ni,nj)*hz*c1(ki,kj)+&
            hx*c1(mi,mj)*hy*c1(ni,nj)*1.d0/hz*b1(ki,kj))
        enddo
    enddo

    call mult_sq(g,b,v,8)
    d = deltaObject(numArea,x1,x2,y1,y2,z1,z2,&
        xObjects,yObjects,zObjects,numbersObjects,&
        nXObjects,nYObjects,nZObjects,nObjects)
    do i=1,8
        g(i)=g(i)*sigma*d
        do j=1,8
            b(i,j)=b(i,j)*sigma
        enddo
    enddo
end
!*************************************************************************
!*************************************************************************
!*************************************************************************